Function: toggleClass(domElementOrNodeArrayOrCSSSelector, stringClassName, boolForceState, functionCallback(currentState)) Description: Toggles a class name on the specified element or set of matching elements. Returns: domElement or matching node array, or $A object if chained. Note: When the boolForceState parameter is omitted, toggleClass will automatically toggle itself using the current state. Otherwise, the boolForceState parameter will force a true or false state to be set. The callback function may be used to perform additional actions relating to the toggle state. When the callback function is passed as the third parameter, then boolForceState is undefined. Example: // Automatically toggle between true or false based on the current state of the class name on the specified element. var myElement = $A.toggleClass(domElement, "selected"); // Automatically toggle the state to true and set class name on the specified element. var myElement = $A.toggleClass(domElement, "selected", true); // Automatically toggle the state to false and remove class name on multiple elements. var myElementsArray = $A.toggleClass([domElement1, domElement2], "button-pressed", false); // Automatically toggle the state to false and remove class name on multiple elements referenced using a CSS selector. var myElementsArray = $A.toggleClass('nav.left button[aria-pressed="false"]', "button-pressed", false); // Automatically toggle between true or false based on the current state of the class name on the specified element, and run a callback to perform additional actions. var myElement = $A.toggleClass(domElement, "selected", function(activeState) { // Do something when activeState is true or false. // 'this' = the DOM element being toggled. }); // Automatically toggle the state to false and remove class name on the specified element, and run a callback to perform additional actions. var myElement = $A.toggleClass(domElement, "selected", false, function(activeState) { // Do something when activeState is true or false. // 'this' = the DOM element being toggled. }); // Or the same using chaining // Automatically toggle the state to false and remove class name on multiple elements. var myChain = $A([domElement1, domElement2]).toggleClass("button-pressed", false); // Automatically toggle the state to false and remove class name on multiple elements referenced using a CSS selector. var myChain = $A('nav.left button[aria-pressed="false"]').toggleClass("button-pressed", false); // To return the modified element within a chain, use the "return()" method. var myElement = myChain.return();